import { defHttp } from '@/utils/http/axios';
import { ErrorMessageMode } from '#/axios';
import {
  AddDictDataItem,
  AddDictTypeItem, DictDataStatusQuery, DictItem, DictTypeStatusQuery,
  GetDictDataListItem,
  GetDictListItem, UpdateDictDataItem,
  UpdateDictTypeItem
} from "@/api/system/model/DictModel";

enum Api {
  //获取所有字典类型列表
  GetAllDictListType = '/dict/allDictListType',
  //新增字典类型
  AddDictType = '/dict/createType',
  //修改字典类型
  UpdateDictType = '/dict/updateType',
  //删除字典类型
  DeleteDictType = '/dict/deleteType/',
  //获取字典数据列表
  GetDictList = '/dict/allDictListData',
  //新增字典数据
  AddDictData = '/dict/createData',
  //修改字典数据
  UpdateDictData = '/dict/updateData',
  //删除字典数据
  DeleteDictData = '/dict/deleteData/',
  //更新数据字典类型状态
  UpdateDictTypeStatus = '/dict/updateTypeStatus',
  //获取字典数据状态
  UpdateDictDataStatus = '/dict/updateDataStatus',
  //根据字典类型获取所有字典数据
  GetDictData = '/dict/getDictData'
}
//根据字典类型获取所有字典数据
export const GetDictData = (params:DictItem) => {
  return defHttp.get<any>({ params:params, url: Api.GetDictData });
}
//获取所有字典类型列表
export const GetAllDictListType = (params:GetDictListItem) => {
  return defHttp.get<any>({ params:params, url: Api.GetAllDictListType });
}
//新增字典类型
export const AddDictType = (params:AddDictTypeItem, mode: ErrorMessageMode = 'message') => {
  return defHttp.post<any>({ params, url: Api.AddDictType },
    {
      errorMessageMode: mode,
    });
}
//修改字典类型
export const UpdateDictType = (params:UpdateDictTypeItem, mode: ErrorMessageMode = 'message') => {
  return defHttp.put<any>({ params, url: Api.UpdateDictType },
    {
      errorMessageMode: mode,
    });
}
//删除字典类型
export const DeleteDictType = (params:number, mode: ErrorMessageMode = 'message') => {
  return defHttp.delete<any>({ url: Api.DeleteDictType + params },
    {
      errorMessageMode: mode,
    });
}
//获取字典数据列表
export const GetDictDataList = (params:GetDictDataListItem) => {
  return defHttp.get<any>({ params:params,url: Api.GetDictList });
}
//新增字典数据
export const AddDictData = (params:AddDictDataItem, mode: ErrorMessageMode = 'message') => {
  return defHttp.post<any>({ params, url: Api.AddDictData },
    {
      errorMessageMode: mode,
    });
}
//修改字典数据
export const UpdateDictData = (params:UpdateDictDataItem, mode: ErrorMessageMode = 'message') => {
  return defHttp.put<any>({ params, url: Api.UpdateDictData },
    {
      errorMessageMode: mode,
    });
}
//删除字典数据
export const DeleteDictData = (params:number, mode: ErrorMessageMode = 'message') => {
  return defHttp.delete<any>({ url: Api.DeleteDictData + params },
    {
      errorMessageMode: mode,
    });
}
//更新数据字典类型状态
export const UpdateDictTypeStatus = (params:DictTypeStatusQuery, mode: ErrorMessageMode = 'message') => {
  return defHttp.put<any>({ params, url: Api.UpdateDictTypeStatus },
    {
      errorMessageMode: mode,
    });
}
//更新数据字典状态
export const UpdateDictDataStatus = (params:DictDataStatusQuery, mode: ErrorMessageMode = 'message') => {
  return defHttp.put<any>({ params, url: Api.UpdateDictDataStatus },
    {
      errorMessageMode: mode,
    });
}
